Public Class EmailRecipients
    Inherits System.Web.UI.Page
    'Dim SchemaNM As String = ConfigurationSettings.AppSettings("GASQLConnString")
#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents adRecpt As System.Web.UI.WebControls.Button

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region
    Dim CompanyId, RecipientID As String
    Dim EmailAddress, RealName As String
    Public pageid As String = "fbadminemail"
    Public strHtml As String
    Dim oFdB As gaFeedBack.FeedBackAdmin
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            strHtml = ""
            GetEmailReptlist()
        Else
            If Not IsNothing(Request.QueryString("del")) > 0 Then
                '-----	deleting a recipient if requested
                oFdB = New gaFeedBack.FeedBackAdmin
                oFdB.DBConnectstring = Application("DSN")
                oFdB.RecipientID = CInt(Request.QueryString("del"))
                oFdB.DeleteFeedbkConts(pageid)

            End If
        End If
    End Sub
    Public Sub GetEmailReptlist()
        '-----	getting current list of email recipients
        Dim rst As New DataSet
        Dim strHtml As String = ""
        Dim i As Integer
        oFdB = New gaFeedBack.FeedBackAdmin
        oFdB.DBConnectstring = Application("DSN")
        rst = oFdB.GetCurrentConts(pageid)

        If Not IsNothing(rst) Or rst.Tables(0).Rows.Count > 0 Then
            strHtml = ""
            strHtml += "<table cellSpacing='1' cellPadding='1' border='0'><tr>"

            strHtml += "<td noWrap align='center'><font face='arial' size='1'>SYSTEM</font></td>"
            strHtml += "<td noWrap align='center'><font face='arial' size='1'>EMAIL</font></td>"
            strHtml += "<td noWrap align='center'><font face='arial' size='1'>REAL NAME</font></td>"
            strHtml += "<td noWrap align='center'><font face='arial' size='1'>&nbsp;</font></td></tr>"
            For i = 0 To rst.Tables(0).Rows.Count - 1
                RecipientID = rst.Tables(0).Rows(i).Item("RecipientID")
                CompanyId = rst.Tables(0).Rows(i).Item("Company_ID")
                EmailAddress = rst.Tables(0).Rows(i).Item("EmailAddress")
                RealName = rst.Tables(0).Rows(i).Item("RealName")

                strHtml += "<tr><td noWrap bgColor='#dddddd'><font face='arial' size='2'>" & CompanyId & "></font></td>"
                strHtml += "<td noWrap bgColor='#dddddd'><font face='arial' size='2'>" & EmailAddress & "></font></td>"
                strHtml += "<td noWrap bgColor='#dddddd'><font face='arial' size='2'>" & RealName & "</font></td>"
                strHtml += "<td noWrap><font face='arial' size='2'><A href='EmailRecipients.asp?del=" & RecipientID & " ' >Delete Recipient</A>"
                strHtml += "</font></td></tr>"


            Next
            strHtml += "</table>"

        Else
            strHtml += "<font face='arial' size='2'>No email recipients found.</font><br>"

        End If
        strHtml += "<hr>"

        'Response.Write(strHtml)
    End Sub
    Private Sub adRecpt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles adRecpt.Click
        'If Request.Form("Director").count > 0 Then
        'If R Then 'equest.Form("Director") = "Add Recipient" Then
        Dim orecipt As gaFeedBack.FeedBackAdmin
        CompanyId = Trim(Request("CompanyID"))
        EmailAddress = Trim(Request.Form("EmailAddress"))
        RealName = Trim(Request.Form("RealName"))
        orecipt = New gaFeedBack.FeedBackAdmin
        'orecipt = Server.CreateObject("viaFeedback.FeedbackAdmin")
        orecipt.DBConnectstring = Application("DSN")
        orecipt.sEmailaddress = EmailAddress
        orecipt.sRealName = RealName
        orecipt.CID = CompanyId
        orecipt.AddConts(pageid)
        orecipt = Nothing

    End Sub
End Class
